@uppy/aws-s3: fix server generated keys not getting returned - #6498
Conversation
🦋 Changeset detectedLatest commit: bb7af70 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
…t/uppy into fix/6496-server-generated-key
| }) | ||
|
|
||
| return { xhr, url } | ||
| return { xhr, url, signedKey: signedKey || request.key } |
There was a problem hiding this comment.
If the key your server signs for is not exactly the key it received, you must return it as key in the response. Otherwise Uppy assumes the object was stored under the key it requested.
This is the directive which we need add in our docs, sadly this wasn't the case previously, before the rewrite we used to return the key from the server
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
i did an ai review: #6507 looks ok? then we can merge both |
| } | ||
| const params = new URLSearchParams({ method: req.method }) | ||
| if (req.uploadId) params.set('uploadId', req.uploadId) | ||
| if (req.partNumber) params.set('partNumber', String(req.partNumber)) |
There was a problem hiding this comment.
What is req.partNumber? If it’s a number, you should check for nullishness instead of booliness. (0 is falsy.)
There was a problem hiding this comment.
now that you mentioned it, I think we could also have typed it better, rather than any,
uppy/packages/@uppy/aws-s3/src/s3-client/types.ts
Lines 27 to 31 in ac1c708
There was a problem hiding this comment.
I will add non-null check for now
fixes #6496
NO AI USED in code
we were always passing client generated keys from s3Opts methods ,
see :
in
#onSuccesswe're passing key returned from putObjectuppy/packages/@uppy/aws-s3/src/S3Uploader.ts
Lines 262 to 279 in 06ae391
putObjectdirectly returns the key it gets in params which is the client generated keyuppy/packages/@uppy/aws-s3/src/s3-client/S3mini.ts
Lines 179 to 201 in 06ae391
people can modify these keys on their signing backends, when a signing backend stores the object under a different key:
Single-part: upload succeeds, but upload-success reports a key that doesn't exist in the bucket. This is the reported issue in In @uppy/aws-s3 6.0, the key returned in file.response.body.key is the client-generated key, not the server-generated one #6496
Multipart: the reported key was correct (it's parsed from S3's
CompleteMultipartUploadresponse), but the client key was used internally for every part/complete/abort request and persisted ass3Multipart.keyforGolden Retriever. That only works if the server maps client→server key deterministically on every call; a server that generates a unique key fails at the firstuploadPartwithNoSuchUpload.Fix